home *** CD-ROM | disk | FTP | other *** search
/ Aminet 13 / Aminet 13 - August 1996.iso / Aminet / dev / e / bits.lha / bits / bits.doc next >
Text File  |  1996-06-08  |  3KB  |  84 lines

  1. bits.m is a little module which supports some procedures which
  2. manipulates values on the bit level.
  3.  
  4. bits.m v1.0 (07-Jun-96) is copyright by:
  5. Ralph Wermke of Digital Innovations
  6. Prokofjewstr. 7B
  7. 17491 Greifswald
  8. Germany
  9. EMail:  wermke@gryps1.rz.uni-greifswald.de
  10. WWW  :  http://www.fh-stralsund.de/~rwermke/di.html
  11.  
  12. !! THIS MODULE IS FREEWARE !!
  13. If you are interested at the source please write me a note.
  14.  
  15. +++++++++++++++++
  16. +++ Functions +++
  17. +++++++++++++++++
  18.  
  19. bitset (value, bit)
  20.  
  21.    Sets the bit 'bit' in 'value'. The valid range for 'bit' is 0-31.
  22.  
  23. bitclear (value, bit)
  24.  
  25.    Clears the bit 'bit' in 'value'. The valid range for 'bit' is 0-31.
  26.  
  27. bittest (value, bit)
  28.  
  29.    Tests the bit 'bit' in 'value' and returns the current state.
  30.    The valid range for 'bit' is 0-31.
  31.  
  32. bitchange (value, bit)
  33.  
  34.    Changes the bit 'bit' in 'value' in the following way 0->1 and 1->0.
  35.    The valid range for 'bit' is 0-31.
  36.  
  37. bitdset (value, bit, dep)
  38.  
  39.    Sets 'dep' to bit 'bit' in 'value'.
  40.    That means that the bit will be set directly to the value in 'dep'.
  41.    The valid range for 'bit' is 0-31.
  42.    'dep' must be 0 or 1.
  43.  
  44. swap (value, what)
  45.  
  46.    This function swaps bytes/words in several ways.
  47.    'what' stays for the kind of swapping.
  48.    The following are supported yet:
  49.    SWAP_LONG   -  swaps both word of a long
  50.                   $11223344 -> $33441122
  51.    SWAP_HIGH   -  swaps the bytes of the high word of a long
  52.                   $11223344 -> $22113344
  53.    SWAP_LOW    -  swaps the bytes of the low word of a long
  54.                   $11223344 -> $11224433
  55.    SWAP_INNER  -  swaps the both inner bytes of a long
  56.                   $11223344 -> $11332244
  57.    SWAP_OUTER  -  swaps the both outer bytes of a long
  58.                   $11223344 -> $44223311
  59.  
  60. bintostr (value, size, str)
  61.  
  62.    Converts the value 'value' to a string 'str ' containing a binary
  63.    number. 'Size' is number of bits to convert.
  64.    For this some values are predefined:
  65.    SIZE_LONG = 32
  66.    SIZE_WORD = 16
  67.    SIZE_BYTE =  8
  68.    But you can also use all values beteen 1 and 32.
  69.    The lenght of the string MUST be at least size+1, if not your
  70.    machine can crash.
  71.  
  72. strtobin (str, size)
  73.  
  74.    With this function you can reconvert a string 'str' which is
  75.    containing a binary number to a normal number (long).
  76.    The function converts 'size' numbers of bits or if the stringlenght
  77.    is shorter till the end of the string.
  78.    For 'size' use the same values as before.
  79.  
  80.  
  81. *** Write me, if you found bugs, have any suggestions or you miss ***
  82. *** a function you need.                                          ***
  83.  
  84.